<?php

$email 			= $this->formText('email',$this->Item['email'],array('class'=>'form-control', 'placeholder' => 'Email'));
$password 		= $this->formPassword('password',$this->Item['password'],array('class'=>'form-control', 'placeholder' => 'Password'));

$linkPost = $this->cmsUrl(array('action'=>'ajax-login'));

$action_page = $this->arrParam['action-page'];

$subTitle = 'ADD A NAME TO THE INTERNATIONAL ARTSERV';
if($action_page == 'add-events'){
	$subTitle = 'POST AN EXHIBITION OR EVENT ANNOUNCEMENT';
}

?>
<div class="row" style="margin: 0px auto !important;">
    <div class="box">
    	<div class="col-md-10 col-md-offset-1 list-error" id="list-error" style="display: none"></div>
    	<div class="clr" class="col-xs-12">
    		<h4 style="margin: 0px 0px 10px 0px; text-align: center" class="col-xs-12">ARTSERV LOGIN</h4>
    		<h5 style="margin: 0px 0px 30px 0px; text-align: center" class="col-xs-12"><?php echo $subTitle?></h5>
    	</div>
		<form class="form-horizontal" role="form" id="appForm" name="appForm" action="<?php echo $linkPost?>" method="post" enctype="multipart/form-data" >
	      	<div class="form-group col-md-12 frm-input">
	        	<label class="col-sm-offset-2 col-xs-3 control-label">EMAIL</label>
			     <div class="col-xs-5" style="margin-left: -25px;">
					<?php echo $email?>
				</div>
	      	</div>
	      	<div class="clr"></div>
	      	<div class="form-group col-md-12 frm-input">
	        	<label class="col-sm-offset-2 col-xs-3 control-label">PASSWORD</label>
			     <div class="col-xs-5" style="margin-left: -25px;">
					<?php echo $password?>
				</div>
	      	</div>
			<div class="form-group col-md-12 frm-input">
				<label class="col-sm-offset-2 col-xs-3 control-label" id="lbl_btn">&nbsp;</label>
			     <div class="col-xs-6" id="area_button" style="margin-left: -25px;">
					<button type="submit" id="btn-register" class="btn btn-default bg-blue" style="margin-right: 10px">REGISTER</button>
					<button type="submit" class="btn btn-default bg-blue" style="margin-right: 30px">LOGIN</button>
				</div>
			</div>
		</form>
	</div>
</div>
<?php
	$linkReturn = $this->cmsUrl(array('action' => $this->arrParam['action-page']));
	$linkLoadUserReg = $this->cmsUrl(array(
										'module' => 'default',
										'controller' => 'index',
										'action' => 'user-register',
									));		
?>
<script>
	$(function(){
		$('#btn-register').on('click',function(){
			$.get("<?php echo $linkLoadUserReg?>", function(data){
                $.fancybox({
                    maxWidth	: '850',
                    minWidth	: '240',
                    scrolling	: 'yes',
                    content : data
                })
			})
			return false;
		})
		
		$('#birthday').datepicker({ format: 'mm/dd/yyyy',});
		
		$('#appForm').ajaxForm({ 
	        // dataType identifies the expected content type of the server response 
	        dataType:  'json', 
	 
	        // success identifies the function to invoke when the server response 
	        // has been received 
	        success: function(data){
	        	$('form[name="appForm"] div.frm-input').addClass('has-success');
	    		$('#list-error').html('').hide();
				if(data.type == "error"){
					for(var x in data.msg){
						$('input#' + x).parent().parent().addClass('has-error');
						$('input#' + x).parent().find('span.glyphicon').removeClass('glyphicon-ok').addClass('glyphicon-remove');
						$('#list-error').append('<div class="alert alert-danger" id="list_device_alert"><strong>' + data.msg[x] + '</strong></div>');
					}
					$('#list-error').fadeIn();
				}else{
					$.get("<?php echo $linkReturn?>", function(data){
                        $.fancybox({
                            maxWidth	: '850',
                            minWidth	: '240',
                            scrolling	: 'yes',
                            content : data
                        })
					});


					$('form[name="appForm"] span.tag').remove();
					$('form[name="appForm"] div.frm-input').removeClass('has-success').removeClass('has-error');
					$('span.form-control-feedback').remove();
					$('#appForm')[0].reset();
					$('#list-error').html('<div class="alert alert-success" id="list_device_alert"><strong>Congratulation! Thank for your registration</strong></div>').fadeIn().delay(3000).fadeOut();
				}
	        } 
	    }); 
	})
	
</script>
